package com.akk.module.avs.service;

import com.akk.module.avs.entity.AvsCustomer;
import com.akk.module.avs.entity.AvsCustomerExample;
import com.akk.module.avs.mapper.AvsCustomerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AvsCustomerService {

    @Autowired
    AvsCustomerMapper avsCustomerMapper;
    @Autowired
    AvsCustomerExample avsCustomerExample;

    public List<AvsCustomer> findAll() {
        avsCustomerExample.clear();
        return avsCustomerMapper.selectByExample(avsCustomerExample);
    }

    public void insert(AvsCustomer customer) {
        avsCustomerMapper.insert(customer);
    }

    public void update(AvsCustomer customer) {
        avsCustomerMapper.updateByPrimaryKey(customer);
    }

    public List<AvsCustomer> findByUniqueIdAndAppId(String userId, String appId) {
        avsCustomerExample.clear();
        avsCustomerExample.createCriteria().andUniqueIdEqualTo(userId).andAppIdEqualTo(appId);
        return avsCustomerMapper.selectByExample(avsCustomerExample);
    }

    public AvsCustomer findByCustomerId(String customerId) {
        return avsCustomerMapper.selectByPrimaryKey(customerId);
    }

    public List<AvsCustomer> findCustomerByYb() {
        avsCustomerExample.clear();
        avsCustomerExample.createCriteria().andYbSubMerIdIsNotNull();
        return avsCustomerMapper.selectByExample(avsCustomerExample);
    }
}
